{
LANG : PASCAL
PROB : ttwo
}
program TTWO;
const
  fi = 'ttwo.in';
  fo = 'ttwo.out';
  dx : array[0..3] of integer = (-1, 0, 1, 0);
  dy : array[0..3] of integer = (0, 1, 0, -1);
  limit = 10000;
type
  point = record
            x, y, d : shortint;
          end;
var
  a : array[0..11, 0..11] of char;
  cows, farmer : point;
  n, step : longint;

procedure inp;
var
  i, j : integer;
begin
  fillchar(a, sizeof(a), '*');
  for i := 1 to 10 do
  begin
    for j := 1 to 10 do read(a[i, j]);
    readln;
  end;
end;

procedure init;
var
  i, j : integer;
begin
  for i := 1 to 10 do
    for j := 1 to 10 do
      case a[i, j] of
        'C' : begin
                cows.x := i;
                cows.y := j;
                cows.d := 0;
                a[i, j] := '.';
              end;
        'F' : begin
                farmer.x := i;
                farmer.y := j;
                farmer.d := 0;
                a[i, j] := '.';
              end;
      end;
end;

procedure done(var target : point);
var
  xt, yt : integer;
begin
  with target do
  begin
    xt := x + dx[d];
    yt := y + dy[d];
    if a[xt, yt] = '*' then d := (d + 1) mod 4
    else
    begin
      x := xt;
      y := yt;
    end;
  end;
end;

procedure process;
begin
  step := 0;
  while (cows.x <> farmer.x) or (cows.y <> farmer.y) do
  begin
    if step > limit then
    begin
      step := 0;
      exit;
    end;
    inc(step);
    done(cows);
    done(farmer);
  end;
end;

begin
  assign(input, fi); reset(input);
  assign(output, fo); rewrite(output);
  inp;
  init;
  process;
  writeln(step);
  close(output);
  close(input);
end.